// SUGARSCAPE MODEL FOR SWARM
// Based on Nelson Minar's 1996-1997 model; modified by 
// Andre Manoel (andremanoel@gmail.com) with research  
// purposes. See file README for more information.

#import <objectbase/Swarm.h>
#import "SugarSpace.h"
#import "SugarAgent.h"
#import  <collections.h> // for ListShuffler

// The model swarm encapsulates all the objects that go into the Sugarscape
//   model. In the simplest case, this is basically a list of agents, a
//   sugarspace world, and various parameters

@interface ModelSwarm: Swarm
{
  // Parameters for the model
  int numAgents;
  
    // sugar/spice pmts.
  int sugarGrowRate, spiceGrowRate;
  float maxSugarMetabolism, maxSpiceMetabolism;
  float minInitialSugar, maxInitialSugar;
  float minInitialSpice, maxInitialSpice;
  float maxSugar, maxSpice;
  int winterDuration, winterGrowRate;             // seasonal growback
  
    // agent life pmts.
  int maxVision;
  int maxForesight;
  int deathAgeMin, deathAgeMax;
  int replacement;				  // use replacement rule?
  int pubertyAgeMin, pubertyAgeMax,		  // sex
      menopauseAgeMin, menopauseAgeMax,
      andropauseAgeMin, andropauseAgeMax;
  int inheritanceOn;                              // flag for inheritance
  int transmitCulture;				  // culture
  int permitCombat, prizeForWinning;		  // combat
  int allowTrading;				  // trade
  int diseaseOn, maxMetabLoss, numDiseases;	  // disease
 
    // environment pmts. 
  int worldXSize, worldYSize;
  int leftXLim, rightXLim, upYLim, downYLim;	  // confines initial set
  int pollutionS, pollutionM, turnsToDiffuse;
  int startPolAt, endPolAt, startDiffAt;
  char *colorsFor;
  char *sugarDatafile, *spiceDatafile;

    // new ideas implemented
  int calcDistEach;				  // prints dist. from origin
  int plagueEach, plagueFor;                      // implements plagues
  
  // Objects in the list
  id agentList;
  id <ListShuffler> shuffler;
  SugarSpace *sugarSpace;
  id reaperQueue;
  int masterDiseaseList[100][15];

  // Schedule stuff
  id modelSchedule;
  
  FILE* popOutput;
}

// Methods to handle the agents in the world
- addNewRandomAgent;
- addNewAgentAtX: (int)x Y: (int)y wSugarEndow: (float)e1 wSpiceEndow: (float)e2
             wVision: (int)v wForesight: (int)f  wSugarMetabol: (float)m1 
             wSpiceMetabol: (float)m2 wTag: (int *)t;
- agentBirth: (SugarAgent *)agent;
- agentDeath: (SugarAgent *)agent;

// Accessor functions
- (SugarSpace *)getSugarSpace;
- getAgentList;
- (char *)getColorsFor;
- (float)getAvgPrice;
- (float)getAvgPriceLogStdDev;
- calculateDistance;

// Scheduling methods
- buildObjects;
- buildActions;
- (id <Activity>)activateIn: swarmContext;

// Other methods
- genDiseaseList;

@end
